
import {
    ElButton,
    ElForm,
    ElFormItem,
    ElInput,
    ElMessage,
    ElContainer,
    ElHeader,
    ElAside,
    ElMain,
    ElMenu,
    ElSubmenu,
    ElMenuItem,
    ElMenuItemGroup,
    ElDropdown,
    ElDropdownItem,
    ElDropdownMenu,
    ElDialog,
    ElBreadcrumb,
    ElBreadcrumbItem,
    ElTable,
    ElTableColumn,
    ElSwitch,
    ElPagination,
    ElLoading,
    ElPopconfirm,
    ElInputNumber,
    ElRow,
    ElCol,
    ElDivider,
    ElSelect,
    ElOption,
    ElCheckbox,
    ElCheckboxGroup,
    ElUpload,
    ElRadio,
    ElImage,
    ElCard,
    ElTooltip,
    ElCascader,
} from 'element-plus';
import { App } from 'vue';


export default (app: App) => {
    app.config.globalProperties.$ELEMENT = { size: 'mini' }
    app.use(ElRadio);
    app.use(ElUpload);
    app.use(ElCheckbox);
    app.use(ElCheckboxGroup);
    app.use(ElOption as any);
    app.use(ElSelect);
    app.use(ElDivider);
    app.use(ElCol as any);
    app.use(ElRow as any);
    app.use(ElButton);
    app.use(ElForm);
    app.use(ElFormItem);
    app.use(ElInput);
    app.use(ElContainer);
    app.use(ElHeader);
    app.use(ElAside);
    app.use(ElMain);
    app.use(ElMenu);
    app.use(ElSubmenu);
    app.use(ElMenuItem);
    app.use(ElMenuItemGroup);
    app.use(ElDropdown);
    app.use(ElDropdownItem);
    app.use(ElDropdownMenu);
    app.use(ElDialog);
    app.use(ElBreadcrumb);
    app.use(ElBreadcrumbItem);
    app.use(ElTable);
    app.use(ElTableColumn as any);
    app.use(ElSwitch);
    app.use(ElPagination as any);
    app.use(ElLoading);
    app.use(ElPopconfirm);
    app.use(ElInputNumber);
    app.use(ElImage);
    app.use(ElCard);
    app.use(ElTooltip as any);
    app.use(ElCascader as any);
}


export const $message = (type: 'success' | 'error', content: string): void => {
    switch (type) {
        case 'success':
            ElMessage.success({
                message: content,
                type: 'success'
            });
            break;
        case 'error':
            ElMessage.error(content);
            break;
    }
}


export const time = (timestamp: number): string => {
    const date: Date = new Date(timestamp * 1000);
    const Y: string = date.getFullYear() + "-";
    const M: string =
        (date.getMonth() + 1 < 10
            ? "0" + (date.getMonth() + 1)
            : date.getMonth() + 1) + "-";
    const D: string = date.getDate() + " ";
    const h: string = date.getHours() + ":";
    const m: string = date.getMinutes() + ":";
    const s: number = date.getSeconds();
    return Y + M + D + h + m + s;
}